package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    /**
     * 分页查询,获取总记录数、当前页展示几条记录
     * @return
     */
//    @Select("select count(*) from emp")
//    Long count();
//    @Select("select * from emp limit #{start},#{pageSize} ")
//    List<Emp> page(Integer start,Integer pageSize);

    /**
     * 用pagehelper插件
     */
//    @Select("select * from emp")
    //这一句，就不用简单的注解映射了，用xml文件映射，所以xml文件中id是这个函数名
    public List<Emp> page(String name, Short gender,
                          LocalDate begin, LocalDate end);


//  @Delete("DELETE * FROM emp where ")
    void deleteByIds(Integer[] ids);//因为是批量去删除，所以是动态的，用动态sql语句<foreach>

    //前面写数据库字段，后面写类中的属性，password是默认的这里不插入
    @Insert("insert into emp (image,username,name,gender,job,entrydate,dept_id,create_time,update_time) " +
            "values (#{image},#{username},#{name},#{gender},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void addemp(Emp emp0);

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getByUsernameAndPassword(Emp emp2);
}
